//- 先去这个pug文件中找
extends ../commons/commons.pug

block append pageStyle
	link(href="${relativePath}/static/css/shopping/shopIndex.css" rel="stylesheet" type="text/css")
	link(href="${relativePath}/static/css/personCenter/securityCenter.css" rel="stylesheet" type="text/css")

block content
	//- 新建订单
	div.newOrderContent
		h3.orderTitle
			| 安全中心
			span -修改登陆密码
		div.setBox.pswBox
			div.row
				label.fl &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;原密码：
				input.txt.fl.psw01(type="password" placeholder="请输入")
			div.row
				label.fl &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;新密码：
				input.txt.fl.pswOne(type="password" placeholder="请输入")
			div.row
				label.fl 确认新密码：
				input.txt.fl.pswTwo(type="password" placeholder="请输入")
			div.row.btnBox
				a.btn.save(href="javascript:;") 保存
				a.btn.cancle(href="javascript:;") 取消


block append pageScript
	script(src="${relativePath}/static/js/jquery.validate.min.js")
	script(src="${relativePath}/static/js/messages_zh.js")
	script(type="text/javascript" src="${relativePath}/static/js/card.js")

	script.
		$(function() {	
			//- 点击保存
			$.post(shopIp+"/user/info",{
				userToken:token
			},function(data) {
				console.log(data);
				$(".phoneNum").val(data.data.phone)
			})
			$(".save").click(function() {
				if($(".psw01").val() == "") {
					layer.msg("请输入原密码");
				} else if($(".pswOne").val() == ""){
					layer.msg("请输入新密码");
				} else if($(".pswTwo").val() == ""){
					layer.msg("请确认新密码");
				} else{
					$.post(shopIp+"/user/modifyPassword",{
						userToken:token,
						old_password:$(".psw01").val(),
						new_password:$(".pswOne").val(),
						repassword:$(".pswTwo").val()
					},function(data){
						if(data.status == "200") {
							layer.msg(data.msg);
							setTimeout(function() {
								window.location.href="securityCenter.html";
							},1500)
						}else {
							layer.msg(data.msg);
						}
					})
				}
			})
			
			//- 点击取消
			$(".cancle").click(function() {
				window.location.href="securityCenter.html";
			})
			
		})
		
		